package wwl.lsf.hellospringboot.test.nio.传统的阻塞;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class TCPClient {

  public static void main(String[] args) throws Exception {

    Socket socket = new Socket("127.0.0.1", 9999);

    OutputStream outputStream = socket.getOutputStream();
    System.out.println("请输入:");
    Scanner scanner = new Scanner(System.in);
    String s = scanner.nextLine();
    outputStream.write(s.getBytes());

    InputStream inputStream = socket.getInputStream();
    byte[] bytes = new byte[20];
    int read = inputStream.read(bytes);
    System.out.println("老板说: " + new String(bytes));


  }


}
